<!-- Copyright 2017 Google Inc. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================-->
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>performance_rnn</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css">
  <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.orange-deep_purple.min.css" />
  <style type="text/css">
    body {
      width: 100%;
      margin: 0;
      padding: 0;
      background-color: #fff;
      font-family: "Roboto", "Helvetica", "Arial", sans-serif;
      color: #7f7f7f;
    }
    #keyboard {
      display: block;
      margin-right: auto;
      margin-left: auto;
      transform: translate(0, 0);
      width: calc(100% - 20px);
      height: 100px
    }
    #container #glow,
    #container #roll,
    body #glow,
    body #roll {
      display: none;
        width: 100%;
        height: calc(100% - 130px);
        top: 0;
        left: 0
    }
    #container #bottom,
    body #bottom {
        width: 100%;
        height: 30px;
        bottom: 0;
        left: 0;
        position: absolute;
        background-color: #222;
        box-shadow: inset 0 12px 30px -5px rgba(0, 0, 0, .75)
    }
    #container.focus {
        -webkit-filter: none;
        filter: none;
        opacity: 1
    }
    #keyboard .key {
        position: absolute;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none
    }
    #keyboard .key {
        height: calc(100% - 2 * 2px);
        width: 10px;
        left: 0;
        top: 0
    }
    #keyboard .key.black {
        z-index: 1;
        height: 50%
    }
    #keyboard .key.black .fill {
        background-color: #7f7f7f;

        width: calc(100% - 8px);
        left: 4px
    }
    #keyboard .key.white {
        z-index: 0
    }
    #keyboard .key.white .fill {
        background-color: #e5e5e5
    }
    #keyboard .key .fill {
        border: 2px solid #d7d7d7;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        transition: background-color 0.6s;
    }
    #keyboard .key .fill.active {
        background-color: #fff;
        transition: background-color 0s;
    }
    #keyboard .key .highlight.ai {
        background-color: #fff
    }

    #status {
      z-index: 10;
      display: block;
      height: auto;
      margin-right: auto;
      margin-left: auto;
      font-size: 26px;
      text-align: center;
      line-height: 200px;
      height: 200px;
    }

    .hidden {
      display: none;
    }
    .image {
      position: absolute;
      left: 0px;
      margin-left: 40px;
    }

    .text-block {
      position: absolute;
      right: 40px;
      width: 450px;
      padding: 20px 0;
      font-size: 15px;
      line-height: 25px;
    }

    .header {
      font-size: 50px;
      line-height: 50px;
      margin-top: 10px;
      width: 100%;
      text-align: center;
      font-weight: bold;
    }

    .link {
      color: #6fc9c6;
    }

    #controls {
      width: 100%;
      text-align: center;
    }

    .control {
      display: inline-block;
      vertical-align: middle;
    }

    .control .pitch {
      width: 3em;
    }

    #conditioning-controls {
      display: inline-block;
    }

    #conditioning-controls.inactive .conditional {
      opacity: .2;
    }

    #conditioning-controls.midicondition .ui-condition {
      opacity: .2;
    }

    a.main-title {
      color: rgb(66,66,66);
      text-decoration: none;
    }
    #midi-out-container, #midi-in-container {
      margin: 10px auto;
    }
    #gain-container {
      margin-top: 5px;
      text-align: center;
    }
    #gain, #note-density {
      width: 150px;
    }
    .histogram-bucket {
      height: 100px;
      position: relative;
    }
    .histogram-value {
      width: 39px;
      height: 70px;
      position: absolute;
      bottom: 0;
      background-color: green;
    }
    #resettingText {
      font-size: 20px;
      transition: opacity 1s;
      text-align: center;
      margin-top: 15px;
    }
  </style>
</head>
<body>
  <!-- Header -->
  <header class="mdl-layout__header mdl-layout--fixed-header">
      <script>
        if (location.protocol !== "https:" &&
            location.hostname === 'deeplearnjs.org') {
          location.protocol = "https:";
        }
      </script>
      <div class="mdl-layout__header-row">
        <!-- Title -->
        <a class="main-title" href="/"><span class="mdl-layout-title">deeplearn.js</span></a>
        <!-- Add spacer, to align navigation to the right -->
        <div class="mdl-layout-spacer"></div>
      </div>
  </header>

  <div id="container">
    <div class="header">Performance RNN</div>
    <div id="status">Loading...</div>
    <div id="controls" class="hidden">
      <div class="control" style="margin-right: 20px;">
        Conditioning<br />
        <input type="radio" name="conditioning" id="conditioning-on">
        On<br />
        <input type="radio" name="conditioning" id="conditioning-off" checked>
        Off
      </div>
      <div id="conditioning-controls">
        <div class="control" style="margin-right: 20px;">
          <div class="conditional">
              Note Density (<span id="note-density-display"></span>)<br/>
              <input type="range" min="0" max="6" value="2" id="note-density"><br />
          </div>

          Gain (<span id="gain-display"></span>%)<br>
          <input type="range" id="gain" min=0 max=200 value=25></input>
        </div>
        <div class="control">
          <div class="conditional">
            <div class="control">
              <div class="histogram-bucket"><div id="hist-c" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-c" type="number" min="0" value="2">
              <br/>
              C
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-cs" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-cs" type="number" min="0" value="0">
              <br/>
              C#
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-d" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-d" type="number" min="0" value="1">
              <br/>
              D
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-ds" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-ds" type="number" min="0" value="0">
              <br/>
              D#
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-e" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-e" type="number" min="0" value="1">
              <br/>
              E
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-f" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-f" type="number" min="0" value="1">
              <br/>
              F
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-fs" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-fs" type="number" min="0" value="0">
              <br/>
              F#
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-g" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-g" type="number" min="0" value="1">
              <br/>
              G
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-gs" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-gs" type="number" min="0" value="0">
              <br/>
              G#
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-a" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-a" type="number" min="0" value="1">
              <br/>
              A
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-as" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-as" type="number" min="0" value="0">
              <br/>
              A#
            </div>
            <div class="control">
              <div class="histogram-bucket"><div id="hist-b" class="histogram-value"></div></div>
              <input class="pitch ui-condition" id="pitch-b" type="number" min="0" value="1">
              <br/>
              B
            </div>
            <br />
            <input type="button" value="C Major" id="c-major" class="ui-condition">
            <input type="button" value="F Major" id="f-major" class="ui-condition">
            <input type="button" value="D Minor" id="d-minor" class="ui-condition">
            <input type="button" value="Whole Tone" id="whole-tone" class="ui-condition">
            <input type="button" value="Pentatonic" id="pentatonic" class="ui-condition">
            <input type="button" value="Preset 1" id="preset-1" class="ui-condition">
            <input type="button" value="Preset 2" id="preset-2" class="ui-condition">
            <br />
            <input type="button" value="Save Preset 1" id="save-1" class="ui-condition">
            <input type="button" value="Save Preset 2" id="save-2" class="ui-condition">
          </div>
          <div id="midi-in-container">
            midi in <select id="midi-in"><option value="none">none</option></select>
          </div>
          <div id="midi-out-container">
              midi out <select id="midi-out"><option value="none">none</option></select>
            </div>
        </div>
      </div>

      <div class="control" style="margin-right: 20px;">
        <input type="button" value="Reset RNN" id="reset-rnn">
      </div>
    </div>
    <div id="keyboard" class="hidden"></div>
    <div id="resettingText" style="opacity: 0">
      Resetting...
    </div>
    <div class="text-block">
      <a href="https://magenta.tensorflow.org/performance-rnn">Performance RNN</a> was trained in TensorFlow on MIDI from piano performances. It was then ported to run in the browser using only Javascript in the <a href="https://deeplearnjs.org/">deeplearn.js</a> environment. Piano samples are from <a href="https://archive.org/details/SalamanderGrandPianoV3">Salamander Grand Piano</a>.
    </div>
    <a href="https://magenta.tensorflow.org/"><img class="image" sizes="128px" src="images/magenta-logo-bottom-text2.png" srcset="images/magenta-logo-bottom-text2.png 500w, images/magenta-logo-bottom-text2.png 640w" width="128"></a>
  </div>

  <!-- Footer -->
  <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-46457317-8', 'auto');
      ga('send', 'pageview');
  </script>
  <script src="bundle.js"></script>
</body>
</html>
